package cn.sofwin.day0107;

import java.util.Scanner;

public class Test04 {
    static Scanner sc = new Scanner(System.in);
    static double money;
    static int tNumber, shoesNumber, batNumber;
    public static void main(String[] args) {
        String keepGoing = "y";
        System.out.println("MyShopping管理系统> 购物结算");
        while("y".equals(keepGoing)){
            keepGoing = shopping();
        }
    }

    static String shopping(){
        System.out.println("************************");
        System.out.println("1.T恤  2.网球鞋  3.网球拍");
        System.out.println("************************");
        System.out.print("请输入商品编号：");
        int goodsId = sc.nextInt();
        System.out.print("请输入购买数量:");
        int number = sc.nextInt();
        switch (goodsId){
            case 1:
                money += (245.0 * number);
                tNumber += number;
                System.out.println("T恤\t¥245.0");
                break;
            case 2:
                money += (570.0 * number);
                shoesNumber += number;
                System.out.println("网球鞋\t¥570.0");
                break;
            case 3:
                money += (320.0 * number);
                batNumber += number;
                System.out.println("网球拍\t¥320.0");
                break;
            default:
                System.out.println("输入有误");
                shopping();
        }
        System.out.println("购物车商品总金额：¥" + money);
        System.out.println("购物车列表：");
        if(tNumber > 0){
            System.out.println("T恤\t\t" + tNumber + "件");
        }
        if(shoesNumber > 0){
            System.out.println("网球鞋\t" + shoesNumber + "双");
        }
        if(batNumber > 0){
            System.out.println("网球拍\t" + batNumber + "副");
        }
        System.out.println("是否继续（y/n）");
        return sc.next();
    }
}
